<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .active {
      color: red;
      font-size: 24px;
      background-color: green;
    }
  </style>
</head>
<body>
  
  <div class="box">
    我是box
  </div>

  <script>

    // 1.获取boxEl
    var boxEl = document.querySelector(".box")

    // 2.监听点击
    var counter = 1
    boxEl.onclick = function() {
      // 1.直接修改style
      // boxEl.style.color = "red"
      // boxEl.style.fontSize = "24px"
      // boxEl.style.backgroundColor = "green"

      // 2.动态的添加某一个class
      boxEl.className = "active"

      // 3.动态的修改boxEl的宽度
      boxEl.style.width = 100 * counter + "px"
      counter++
    }

  </script>

</body>
</html>